package cn.yunyichina.provider.base.service.impl;

import cn.yunyichina.provider.base.dao.RoleDao;
import cn.yunyichina.provider.base.dao.RuleDao;
import cn.yunyichina.provider.base.entity.Role;
import cn.yunyichina.provider.base.entity.Rule;
import cn.yunyichina.provider.base.service.OrgService;
import cn.yunyichina.provider.base.utils.CacheConstant;
import cn.yunyichina.provider.framework.common.PKGenerator;
import cn.yunyichina.provider.framework.dubbo.service.CacheService;
import cn.yunyichina.provider.iface.entity.base.Org;
import cn.yunyichina.provider.iface.entity.cache.SessionInfo;
import cn.yunyichina.provider.iface.entity.common.Response;
import cn.yunyichina.utils.commons.DateUtils;
import cn.yunyichina.utils.convert.JsonUtils;
import com.alibaba.dubbo.common.utils.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 
 * @projectName:yyt-provider-base
 * @author:wwb
 * @description:角色
 * @date:2017年11月23日
 * @className:RoleServiceImpl
 * @pakeage:cn.yunyichina.provider.base.service.impl
 */
@Service
public class RoleServiceImpl {
	private static final Logger logger = LoggerFactory.getLogger(RoleServiceImpl.class);
	@Autowired
	private RoleDao roleDao;


	/**
	 * 
	 * @methodName:selectRule yyt.base.role.by.login.name.select
	 * @description:根据用户登录账号获取角色
	 * @date:2017年11月23日
	 * @param data
	 * @return:Response
	 */
	public Response selectRoleByLoginName(String data) {
		Response response = new Response();
		Map<String, String> map = JsonUtils.parseObject(data, Map.class);
		String login_name = map.get("login_name");

		if(StringUtils.isBlank(login_name)){
			response.setResultCodeAndMessage("1101", "login_name不能为空");
			return response;
		}

		List<Role> list = roleDao.selectRoleByLoginName(login_name);
		response.setResultCodeAndMessageAndResult("0", "成功", JsonUtils.toJsonString(list));
		return response;
	}




}
